import request from '../utils/request';
import {baseServerUrl} from "../utils/Constant";
import {stringify} from "qs";


export async function resourceTypeList(params) {
  return request(baseServerUrl + `/user/sys-resource-type/page?${stringify(params)}`,{
    method: 'GET'
  });
}

export async function resourceTypeInsert(params) {
  return request(`${baseServerUrl}/user/sys-resource-type`, {
    method: 'POST',
    body: {
      ...params,
      method: 'post',
    }
  })
}

export async function resourceTypeDel(params) {
  return request(`${baseServerUrl}/user/sys-resource-type`, {
    method: 'DELETE',
    body: {
      ...params,
      method: 'delete'
    }
  })
}

export async function resourceTypeEdit(params) {
  return request(`${baseServerUrl}/user/sys-resource-type`, {
    method: 'PUT',
    body: {
      ...params,
      method: 'put'
    }
  })
}

export async function resourceList() {
  return request(baseServerUrl + '/user/sys-resource/list',{
    method: 'GET'
  });
}

export async function resourceInsert(params) {
  return request(`${baseServerUrl}/user/sys-resource`, {
    method: 'POST',
    body: {
      ...params,
      method: 'post',
    }
  })
}

export async function resourceDel(params) {
  return request(`${baseServerUrl}/user/sys-resource`, {
    method: 'DELETE',
    body: {
      ...params,
      method: 'delete'
    }
  })
}

export async function resourceEdit(params) {
  return request(`${baseServerUrl}/user/sys-resource`, {
    method: 'PUT',
    body: {
      ...params,
      method: 'put'
    }
  })
}

export async function inlineElemPage(params) {
  return request(baseServerUrl + `/user/sys-resource/inlineElem?${stringify(params)}`,{
    method: 'GET'
  });
}

export async function btnGroupPage(params) {
  return request(baseServerUrl + `/user/sys-resource/bntGroup?${stringify(params)}`,{
    method: 'GET'
  });
}

export async function elemsData(params) {
  return request(`${baseServerUrl}/user/sys-menu-elem/transfer?${stringify(params)}`, {
    method: 'GET'
  })
}

export async function saveMenuElem(params) {
  let body = new FormData();
  Object.keys(params).map(key => {
    body.append(key,params[key]);
  })
  return request(`${baseServerUrl}/user/sys-menu-elem/save`, {
    method: 'POST',
    body: body
  })
}
